import junit.framework.TestCase;

public class LiczbaTest extends TestCase {

	
	protected void setUp() throws Exception {
		super.setUp();
		
	}

	public void testKonstruktorDomyslny() throws Exception {
		Liczba l = new Liczba();
		for(int i=2; i<=16; i++) {
			assertNotNull(l.zapis(i));
//			assertTrue(l.zapis(i)=="0");
//			assertFalse(l.zapis(i)!="0");
//			assertSame(l.zapis(i),"0");
			
		}
	}
	
	public void testZaMalaPodstawa() throws Exception {
		try{
			new Liczba("10", 1);
			fail("Oczekiwany LiczbaException");
			
		}
		catch(LiczbaException ex) {
			
		}
		
	}
	
	public void testZaDuzaPodstawa() throws Exception {
		try {
			new Liczba("10", 17);
			fail("Oczekiwany LiczbaException");
		}
		catch(LiczbaException ex) {
		}
	}
	
	public void testPodstawaWZapisieZaMala() throws Exception {
		try {
			new Liczba("10", 10).zapis(1);
			fail("Oczekiwany LiczbaException");
		}
		catch (LiczbaException ex) {
			
		}
	}

	
	public void testPodstawaWZapisieZaDuza() throws Exception {
		try {
			new Liczba("10", 17).zapis(1);
			fail("Oczekiwany LiczbaException");
		}
		catch (LiczbaException e) {
			
		}
	}
	
	public void testZapis() throws Exception {
		String[] in = {"27", "36", "72"};
		String[][] out = {
				{"11011", "1000", "123", "102", "43", "36", "33", "30", "27", "25", "23", "21", "1D", "1C", "1B"},
				{"100100", "1100", "210", "121", "100", "51", "44", "40", "36", "33", "30", "2A", "28", "26", "24"}, 
				{"1001000", "2200", "1020", "242", "200", "132", "110", "80", "72", "66", "60", "57", "52", "4C", "48"}
		};
		for(int i=0; i<in.length; i++) {
			Liczba l = new Liczba(in[i], 10);
			for(int k = 0; k<out.length; k++) {
				assertEquals(l.zapis(k+2),out[i][k]);
			}
			
		}
	}
	
	protected void tearDown() throws Exception {
		super.tearDown();
	}

}